Functional MRI, diffusion MRI and MRS have great potential for the study and diagnosis of brain disease and injury, and guiding surgical therapy. All of these methods benefit greatly from the added sensitivity and contrast from high field strength magnets (3T and above). However, the advantages of higher magnetic fields have not been fully realized due to the increasingly confounding effects of magnetic field inhomogeneity (MFI) caused by magnetic susceptibility differences between air and tissue. MFI leads to signal loss and spatial distortion in MRI and loss in spectral resolution and sensitivity in MRS. The loss of reliability due to these artifacts is a major reason why these techniques have not seen wide use in clinical applications. Current methods of magnetic field homogenization (i.e. shimming) work well on small volumes but are inadequate over the entire human brain. Here we propose a number of novel techniques that are aimed at the global optimization of magnetic fields in human and animal brain in vivo. (1) Dynamic shim updating divides a global 3D problem into a number of slices over which adequate magnetic field homogeneity can be achieved. Dynamically updating the pre-determined slice shims in sync with the multi-slice MRI sequence ensures optimal homogeneity for all slices. (2) Local passive shims made from strong dia-and paramagnetic materials will be constructed to provide highly localized compensation of inhomogeneities. (3) The development of a gradient/shim coil assembly based on in vivo magnetic field distributions in the mouse brain will lead to a better use of shim currents and hence an improved homogeneity. (4) While spatial and temporal B0 variations are not directly related to MFI, they can affect MRI and MRS results in a similar manner. Here we propose to characterize B0 field variations and build a digital compensation unit. During the R21 phase, we will implement DSU and provide a complete characterization of MFI in vivo. The R33 phase is dominated by the construction and testing of passive shims, optimized shim/gradient coils and a B0 compensation unit. Once all the techniques are fully developed it is anticipated that MFI in the human and animal brain are reduced to levels in which they do not pose a limitation to the majority of MRI/MRS applications. Since MFI affects many facet's of in vivo NMR, the proposed techniques will have major impacts on almost all aspects of MRI and MRS. [unreadable] [unreadable]